package oop.core.view.listeners;

public class InventoryIndexCalculator {
	/**
	 * This class calculates the index of an item clicked in the inventory window
	 * it returns the index, or -1 if the mouse click event didn't happen on pixil coordinates
	 * falling off of a proper item location.
	 * @author srhinson
	 */
	
	public int getCode(int x, int y)
	{
		int codeX = x/50;
		int codeY = y/50;
		int checkX= x%50;
		int checkY= x%50;
		if ((codeX>7)||(codeY>3)){
			return -1;
		}
		if ((checkX<=10)||(checkY<=10)){
			return -1;
		}
		int code=codeY*8+codeX;
		return code;
	}
}
